//prevzate z http://techpatterns.com/downloads/javascript_cookies.php
function setSesId(sesid) {
	setCookie('sesId', sesid, 0, '', '', '');
}

function getSesId() {
	return getCookie('sesId');
}

function unsetSesId() {
	deleteCookie('sesId', '', '');
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
										((expires) ? ";expires=" + expires_date.toGMTString() : "" ) + 
										((path) ? ";path=" + path : "" ) + 
										((domain) ? ";domain=" + domain : "" ) +
										((secure)? ";secure" : "" );
}

function getCookie(checkName) {
	var aAllCookies = document.cookie.split(';');
	var aTempCookie = '';
	var cookieName = '';
	var cookieValue = '';
	var bCookieFound = false; 
	
	for ( i = 0; i < aAllCookies.length; i++ ) {
		aTempCookie = aAllCookies[i].split( '=' );
		
		cookieName = aTempCookie[0].replace(/^\s+|\s+$/g, '');
		
		if ( cookieName == checkName ) {
			bCookieFound = true;
			
			if ( aTempCookie.length > 1 ) {
				cookieValue = unescape( aTempCookie[1].replace(/^\s+|\s+$/g, ''));
			}
			return cookieValue;
			break;
		}
		aTempCookie = null;
		cookieName = '';
	}
	if ( !bCookieFound )
	{
		return null;
	}
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
											((path) ? ";path=" + path : "") +
											((domain) ? ";domain=" + domain : "" ) +
											";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

function setRealName(realName) {
	setCookie('realName', realName, 0, '', '', '');
}

function setUserName(usrName) {
	setCookie('usrName', usrName, 0, '', '', '');
}



function setUsrId(usrId) {
	setCookie('usrId', usrId, 0, '', '', '');
}

function getRealName() {
	return getCookie('realName');
}

function getUserName() {
	return getCookie('usrName');
}



function getUsrId() {
	return getCookie('usrId');
}

function unsetRealName() {
	deleteCookie('realName', '', '');
}

function unsetUserName() {
	deleteCookie('usrName', '', '');
}

function unsetUsrId() {
	deleteCookie('usrId', '', '');
}

function setLanguage(langId) {
	setCookie('selectedLanguage', langId, 3000, '', '', '');
}

function getLanguage() {
	return getCookie('selectedLanguage');
}

function setVisit() {
	setCookie('visit', 1, 30000, '', '', '');
}

function getVisit() {
	return getCookie('visit');
}
